package rpc

import (
	"bufio"
	"fmt"
	"log"
	"net/rpc"
	"os"
)

func StartClient() {

	client, err := rpc.Dial("tcp", "127.0.0.1:8080")
	if err != nil {
		panic(err)
	}

	if client != nil {
		log.Println("client connect success")
	}

	in := bufio.NewReader(os.Stdin)

	for {
		line, _, err := in.ReadLine()
		if err != nil {
			log.Fatal(err)
		}
		log.Printf("Client: %s", string(line))
		var reply bool
		err = client.Call("Listen.GetLine", line, &reply)
		if err != nil {
			log.Fatal(err)
		} else {
			fmt.Println(reply)
		}

	}

}
